﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YXQ.Common.Helper;
using YXQ.Dao.ViewModel;
using YXQ.Service;

namespace YXQ.Manager.Manager
{
    public partial class ProjectShow : BaseAdminPage
    {
        BJModel bjmodel = new BJModel();
        SJModel sjmodel = new SJModel();
        YSJSModel ysjsmodel = new YSJSModel();
        ZBBModel zbbmodel = new ZBBModel();
        GCBModel gcbmodel = new GCBModel();
        ZGCSModel zgcsmodel = new ZGCSModel();
        DAModel damodel = new DAModel();
        CWModel cwmodel = new CWModel();
        int tpid = 0;
        MudleModel pmodel = new MudleModel();
        public int colums = 0;
        public int seclum = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request["tpid"] != null)
            {
                tpid = Convert.ToInt32(Request["tpid"]);
            }

            if (!IsPostBack) {
                pmodel = CenterService.mudleService.GetOneById(tpid);
                GetData();
            }
        }

        private void GetData()
        {
            #region 报建部 
            bjmodel = CenterService.bJService.GetOneByProjectId(reqID);
            if (bjmodel != null) {
                //立项
                ltrLx.Text =bjmodel.lx==4?"": EnumHelper.EnumConvert(1, bjmodel.lx);
                ltrOther.Text = bjmodel.lxother;
                ////可研
                //ltrKy.Text =bjmodel.ky==4?"": EnumHelper.EnumConvert(1,bjmodel.ky);
                //ltrKyOther.Text = bjmodel.kyother;
                //选址
                ltrXZ.Text =bjmodel.xzyj==4?"": EnumHelper.EnumConvert(1, bjmodel.xzyj);
                ltrXZOther.Text = bjmodel.xzyjother;
                //用地
                ltrYd.Text =bjmodel.ydgh==4?"": EnumHelper.EnumConvert(1,bjmodel.ydgh);
                ltrYdOther.Text = bjmodel.ydghother;
                //方案审查
                ltrFasc.Text =bjmodel.fasc==4?"": EnumHelper.EnumConvert(1,bjmodel.fasc);
                ltrFascOther.Text = bjmodel.fascother; 
                //建设工程
                ltrGcxk.Text =bjmodel.jsgc==4?"": EnumHelper.EnumConvert(1, bjmodel.jsgc);
                ltrGcxkOther.Text = bjmodel.jsgcother;
                //初设审查
                ltrCssc.Text =bjmodel.cssc==4?"": EnumHelper.EnumConvert(1,bjmodel.cssc);
                ltrCsscOther.Text = bjmodel.csscother;
                //施工图备案
                ltrSgbt.Text =bjmodel.sgbt==4?"": EnumHelper.EnumConvert(1, bjmodel.sgbt);
                ltrSgbtOther.Text = bjmodel.sgbtother;
                //质监 
                ltrZj.Text =bjmodel.zj==4?"": EnumHelper.EnumConvert(1, bjmodel.zj);
                ltrZjOther.Text = bjmodel.zjother;
                //安监 
                ltrAj.Text = bjmodel.aj == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.aj);
                ltrAjOther.Text = bjmodel.ajother;
                //施工许可 
                ltrSgxk.Text = bjmodel.sgxk == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.sgxk);
                ltrSgxkOther.Text = bjmodel.sgxkother;
                //消防方案审查 
                ltrxffa.Text = bjmodel.xffa == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.xffa);
                ltrxffaother.Text = bjmodel.xffaother;
                //消防初设审查 
                ltrxffasc.Text = bjmodel.xffacs == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.xffacs);
                ltrxffascOther.Text = bjmodel.xffacsother;
                //环保审查 
                ltrhbsc.Text = bjmodel.hbsc == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.hbsc);
                ltrhbscOther.Text = bjmodel.hbscother;
                //市政审查意见 
                ltrszsc.Text = bjmodel.szsc == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.szsc);
                ltrszscOther.Text = bjmodel.szscother;
                //园林审查意见 
                ltrylsc.Text = bjmodel.ylsc == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.ylsc);
                ltrylscOther.Text = bjmodel.ylscother;
                //规划验收 
                ltrghys.Text = bjmodel.ghys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.ghys);
                ltrghysOther.Text = bjmodel.ghysother;
                //国土验收 
                ltrgtys.Text = bjmodel.gtys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.gtys);
                ltrgtysOther.Text = bjmodel.gtysother;
                //消防验收 
                ltrxfys.Text = bjmodel.xfys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.xfys);
                ltrxfysOther.Text = bjmodel.xfysother;
                //防雷检测 
                ltrfljc.Text = bjmodel.fljc == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.fljc);
                ltrfljcOther.Text = bjmodel.fljcother;
                //市政园林验收 
                ltrylys.Text = bjmodel.ylys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.ylys);
                ltrylysOther.Text = bjmodel.ylysother;
                //市政园林验收 
                ltrhbys.Text = bjmodel.hbys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.hbys);
                ltrhbysOther.Text = bjmodel.hbysother;
                //竣工备案 
                ltrjgba.Text = bjmodel.jgba == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.jgba);
                ltrjgbaOther.Text = bjmodel.jgbaother;
                ltrflhz.Text = bjmodel.flhz == 4 ? "" : EnumHelper.EnumConvert(1,bjmodel.flhz);
                ltrflhzOther.Text = bjmodel.flhzother;
                ltrrff.Text = bjmodel.rff == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.rff);
                ltrrffOther.Text = bjmodel.rffother;
                ltrhppz.Text = bjmodel.hppz == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.hppz);
                ltrhppzOther.Text = bjmodel.hppzother;
                ltrtsba.Text = bjmodel.tsba == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.tsba);
                ltrtsbaOther.Text = bjmodel.tsbaother;
                ltrrfys.Text = bjmodel.rfys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.rfys);
                ltrrfysOther.Text = bjmodel.rfysother;
                ltrszys.Text = bjmodel.szys == 4 ? "" : EnumHelper.EnumConvert(1, bjmodel.szys);
                ltrszysOther.Text = bjmodel.szysother;
            }
            #endregion
            #region 设计部
            sjmodel = CenterService.sJService.GetOneByProjectId(reqID);
            if (sjmodel != null) {
                //方案设计
                ltrfasj.Text = sjmodel.fasj == 4 ? "" : EnumHelper.EnumConvert(1, sjmodel.fasj);
                ltrfasjOther.Text = sjmodel.fasjother;
                //地质勘察
                ltrdzkc.Text = sjmodel.dzkc == 4 ? "" : EnumHelper.EnumConvert(2, sjmodel.dzkc);
                ltrdzkcOther.Text = sjmodel.dzkcother;
                //初步设计
                ltrcbsj.Text = sjmodel.cbsj == 4 ? "" : EnumHelper.EnumConvert(3, sjmodel.cbsj);
                ltrcbsjOther.Text = sjmodel.cbsjother;
                //施工图设计
                ltrsgt.Text = sjmodel.sgt == 4 ? "" : EnumHelper.EnumConvert(3, sjmodel.sgt);
                ltrsgtOther.Text = sjmodel.sgtother;
                //施工图审查
                ltrsgtsc.Text = sjmodel.sgtsc == 4 ? "" : EnumHelper.EnumConvert(4, sjmodel.sgtsc);
                ltrsgtscOther.Text = sjmodel.sgtscother;
                //施工设计变更
                ltrsgtbg.Text = sjmodel.sgtbg == 4 ? "" : EnumHelper.EnumConvert(3, sjmodel.sgtbg);
                ltrsgtbgOther.Text = sjmodel.sgtbgother;
                //工程技术控制
                ltrgcjs.Text = sjmodel.gcjs;
                ltrgcsf.Text = sjmodel.gcsf;
                ltrgcys.Text = sjmodel.gcys;
                ltryskz.Text = sjmodel.jggl;
       

            }
            #endregion 
            #region 获取预算结算部 
            ysjsmodel = CenterService.ySJSService.GetOneByProjectId(reqID);
            if (ysjsmodel != null) {
                //概算
                ltrgs.Text = ysjsmodel.gs == 4 ? "" : EnumHelper.EnumConvert(5, ysjsmodel.gs);
                ltrgsOther.Text = ysjsmodel.gsother;
                //预算编制
                ltrysbz.Text = ysjsmodel.ysbz == 4 ? "" : EnumHelper.EnumConvert(5, ysjsmodel.ysbz);
                ltrysbzOther.Text = ysjsmodel.ysbzother;
                //预算评审
                ltrysps.Text = ysjsmodel.ysps == 4 ? "" : EnumHelper.EnumConvert(6, ysjsmodel.ysps);
                ltryspsOther.Text = ysjsmodel.yspsother;
                //招标限价
                ltrzbxj.Text = ysjsmodel.zbxj.ToString();
                //结算审查（50万以下）
                ltrjssc.Text = ysjsmodel.jssc == 4 ? "" : EnumHelper.EnumConvert(7, ysjsmodel.jssc);
                ltrjsscOther.Text = ysjsmodel.jsscother;
                ltrjsje.Text = ysjsmodel.jsje.ToString();
                //结算评审（50-200万）
                ltrjsps.Text = ysjsmodel.jsps == 4 ? "" : EnumHelper.EnumConvert(8, ysjsmodel.jsps);
                ltrjspsOther.Text = ysjsmodel.jspsother;
                ltrjspsje.Text = ysjsmodel.jspsje.ToString();
                //结算审计（200万以上）
                ltrjssj.Text = ysjsmodel.jssj == 4 ? "" : EnumHelper.EnumConvert(8, ysjsmodel.jssj);
                ltrjssjOther.Text = ysjsmodel.jssjother;
                ltrjssjje.Text = ysjsmodel.jssjje.ToString();
                ltrzzsjje.Text = ysjsmodel.zzsjje.ToString();

                //设置财务
                ltrsjje.Text = ysjsmodel.zzsjje.ToString();
                ltrgcyfk.Text = ysjsmodel.zzsjje.ToString();

            }
            #endregion
            #region  招标办
            zbbmodel = CenterService.zBBService.GetOneByProjectId(reqID);
            if (zbbmodel != null) {
                //委托代理机构
                ltrwtdljg.Text = zbbmodel.wtdljg;
                ltrzbfs.Text = zbbmodel.zbfs == 4 ? "" : EnumHelper.EnumConvert(9, zbbmodel.zbfs);
                ltrdlhtje.Text = zbbmodel.dlhtje.ToString();
                ltrdlfkfs.Text = zbbmodel.dlfkfs;

                //中标单位及合同 
                ltrzbdw.Text = zbbmodel.zbdw;
                zbtzs.Text = zbbmodel.zbtzs == 4 ? "" : EnumHelper.EnumConvert(10, zbbmodel.zbtzs);
                ltrzbje.Text = zbbmodel.zbje.ToString();
                ltrlybzj.Text = zbbmodel.lybzj == 4 ? "" : EnumHelper.EnumConvert(10, zbbmodel.lybzj);
                ltrsght.Text = zbbmodel.sght == 4 ? "" : EnumHelper.EnumConvert(10, zbbmodel.sght);
                ltrgclybzj.Text = zbbmodel.gclybzj.ToString() ;
                ltrgcfkfs.Text = zbbmodel.gcfkfs;

                //委托监理单位及合同 
                ltrjldw.Text = zbbmodel.jldw;
                ltrjlfwf.Text = zbbmodel.jlfwf.ToString();
                ltrjllybzj.Text = zbbmodel.jllybzj.ToString();
                ltrjlfkfs.Text = zbbmodel.jlfkfs;
                //委托跟审单位及合同
                ltrgsdw.Text = zbbmodel.gsdw;
                ltrgsfwf.Text = zbbmodel.gsfwf.ToString();
                ltrgsfkfs.Text = zbbmodel.gsfkfs;
                //委托设计单位及合同
                ltrsjdw.Text = zbbmodel.sjdw;
                ltrsjfwf.Text = zbbmodel.sjfwf.ToString();
                ltrsjlybzj.Text = zbbmodel.sjlybzj.ToString();
                ltrsjfkfs.Text = zbbmodel.sjfkfs;
                //委托地勘单位及合同
                ltrdzkc.Text = zbbmodel.kcdw;
                ltrkcfwf.Text = zbbmodel.kcfwf.ToString() ;
                ltrkcfkfs.Text = zbbmodel.kcfkfs;

                //委托造价单位及合同
                ltrzjdw.Text = zbbmodel.zjdw;
                ltrzxf.Text = zbbmodel.zxf.ToString();
                ltrzjfkfs.Text = zbbmodel.zjfkfs;
                //采购供货单位及合同
                ltrghdw.Text = zbbmodel.ghdw;
                ltrghht.Text = EnumHelper.EnumConvert(10, zbbmodel.ghht);
                ltrghje.Text = zbbmodel.ghje.ToString();
                ltrghfkfs.Text = zbbmodel.ghfkfs;
                
                //设置财务需要读取的数据
                ltrSgdw.Text = zbbmodel.sjdw;
                ltrglybzj.Text = zbbmodel.gclybzj.ToString();
                ltrhtje.Text = zbbmodel.zbje.ToString();
                ltrgfkfs.Text = zbbmodel.gcfkfs;
                ltrssjdw.Text = zbbmodel.sjdw;
                ltrslybzj.Text = zbbmodel.sjlybzj.ToString();
                ltrsjhtje.Text = zbbmodel.sjfwf.ToString();
                ltrsfkfs.Text = zbbmodel.sjfkfs;
                ltrjjldw.Text = zbbmodel.jldw;
                ltrjlybzj.Text = zbbmodel.jllybzj.ToString();
                ltrjlhtje.Text = zbbmodel.jlfwf.ToString();
                ltrjfkfs.Text = zbbmodel.jlfkfs;
                ltrkkcdw.Text = zbbmodel.kcdw;
                ltrkchtje.Text = zbbmodel.kcfwf.ToString();
                ltrkfkfs.Text = zbbmodel.kcfkfs;
                ltrggsdw.Text = zbbmodel.gsdw;
                ltrgshtje.Text = zbbmodel.gsfwf.ToString();
                ltrggfkfs.Text = zbbmodel.gsfkfs;
                ltrzzjdw.Text = zbbmodel.zjdw;
                ltrzjje.Text = zbbmodel.zxf.ToString();
                ltrzfkfs.Text = zbbmodel.zjfkfs;
                ltrdldw.Text = zbbmodel.wtdljg;
                ltrdlje.Text = zbbmodel.dlhtje.ToString();
                ltrddlfkfs.Text = zbbmodel.dlfkfs;
                ltrcgdw.Text = zbbmodel.ghdw;
                ltrghhtje.Text = zbbmodel.ghje.ToString();
                ltrcgfkfs.Text = zbbmodel.ghfkfs;
                
            }
            #endregion
            #region  工程部
            gcbmodel = CenterService.gCBService.GetOneByProjectId(reqID);
            if (gcbmodel != null) {
                ltrgctj.Text = gcbmodel.gctj;
                ltrtjwt.Text = gcbmodel.tjwt;
                ltrldjj.Text = gcbmodel.ldjj;
                ltrxyxt.Text = gcbmodel.xyxt;
                ltrgczl.Text = EnumHelper.EnumConvert(11, gcbmodel.gczl);
                ltrgcaq.Text = EnumHelper.EnumConvert(11, gcbmodel.gcaq);
                ltrgcysrq.Text = gcbmodel.gcysrq.HasValue? gcbmodel.gcysrq.Value.ToString("yyyy-MM-dd"):"";
                ltrsjysrq.Text =  gcbmodel.sjysrq.HasValue? gcbmodel.sjysrq.Value.ToString("yyyy-MM-dd"):"";
                ltrjlysrq.Text = gcbmodel.jlysrq.HasValue?gcbmodel.jlysrq.Value.ToString("yyyy-MM-dd"):"";

                //设置财务
                ltrgysrq.Text = gcbmodel.gcysrq.HasValue ? gcbmodel.gcysrq.Value.ToString("yyyy-MM-dd") : "";
                ltrsysrq.Text = gcbmodel.sjysrq.HasValue ? gcbmodel.sjysrq.Value.ToString("yyyy-MM-dd") : "";
                ltrjysrq.Text = gcbmodel.jlysrq.HasValue ? gcbmodel.jlysrq.Value.ToString("yyyy-MM-dd") : "";
            }
            #endregion
            #region 档案室
            damodel = CenterService.dAService.GetOneByProjectId(reqID);
            if (tpid == 2)
            {
                ltrJC.Text = "基础验收<br/>(房建基础完工转序)";
                tr1.Visible = true;
                tr2.Visible = true;
                colums = 8;
                seclum = 6;
            }
            else if (tpid == 3)
            {
                ltrJC.Text = "土石方验收";
                tr1.Visible = true;
                tr2.Visible = false;
                colums = 7;
                seclum = 5;
            }
            else
            {
                tr1.Visible = false;
                tr2.Visible = false;
                colums = 6;
                seclum = 4;
            }
            if (pmodel != null)
            {
                ltrProName.Text = pmodel.Title;
            }

            if (damodel != null)
            {
               
                ltrjs.Text = damodel.sjjs;
                ltrDajd.Text = damodel.dajd == 4 ? "" : EnumHelper.EnumConvert(12, damodel.dajd);
                ltrDajdOther.Text = damodel.dajdother;
                ltrjcys.Text = damodel.jcys == 4 ? "" : EnumHelper.EnumConvert(12, damodel.jcys);
                ltrJcysOther.Text = damodel.jcysother;

                ltrztys.Text = damodel.ztys == 4 ? "" : EnumHelper.EnumConvert(12, damodel.ztys);
                ltrztysOther.Text = damodel.ztysother;
                ltrdzzx.Text = damodel.dzzx == 4 ? "" : EnumHelper.EnumConvert(12, damodel.dzzx);
                ltrdzzxOther.Text = damodel.dzzxother;
                ltrwgys.Text = damodel.wgys == 4 ? "" : EnumHelper.EnumConvert(12, damodel.wgys);
                ltrwgysOther.Text = damodel.wgysother;
                ltryjjs.Text = damodel.yjjs == 4 ? "" : EnumHelper.EnumConvert(12, damodel.yjjs);
                ltryjjsOther.Text = damodel.yjjsother;
                ltrcgrq.Text = damodel.cgrq.HasValue?damodel.cgrq.Value.ToString("yyyy-MM-dd"):"";
                
            }
            #endregion
            #region  财务室
            cwmodel = CenterService.cWService.GetOneByProjectId(reqID);
            if (cwmodel != null) {
                ltrgcyf.Text = cwmodel.gcyf.ToString();
                ltrgcyt.Text = cwmodel.gcyt.ToString();
                ltrsjyf.Text = cwmodel.sjyf.ToString();
                ltrsjyt.Text = cwmodel.sjyt.ToString();
                ltrjlzj.Text = cwmodel.jlzj.ToString();
                ltrjlyf.Text = cwmodel.jlyf.ToString();
                ltrjlyt.Text = cwmodel.jlyt.ToString();
                ltrkcfkhj.Text = cwmodel.kcyf.ToString();
                ltrgsfkhj.Text = cwmodel.gsyf.ToString();
                ltrzjfkhj.Text = cwmodel.zjyf.ToString();
                ltrdlfkhj.Text = cwmodel.dlyf.ToString();
                ltrcgfkhj.Text = cwmodel.cgyf.ToString();
                ltrqtdw.Text = cwmodel.qtfkdw;
                ltrqthtje.Text = cwmodel.qthtje.ToString();
                ltrqtfyms.Text = cwmodel.qtfyms;
                ltrqthj.Text = cwmodel.qtyf.ToString() ;
            }

            #endregion
            
        }
    }
}